<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="demo"></div>

  <svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
    <polygon points="220,100 300,210 170,250" style="fill:#cccccc;
  stroke:#000000;stroke-width:1" />
  </svg>

  <script>

    var x = document.getElementById("demo");
    function getLocation() {
      if (navigator.geolocation) {
        console.log(111)
        navigator.geolocation.getCurrentPosition(showPosition);
      }
      else {
        x.innerHTML = "该浏览器不支持获取地理位置。";
      }
    }

    function showPosition(position) {
      x.innerHTML = "纬度: " + position.coords.latitude +
        "<br>经度: " + position.coords.longitude;
    }
    getLocation()
    // HTML 5新增的地理定位
    // navigator.geolocation.getCurrentPosition(function(position){
      // position 有经度和纬度
    // }));
  </script>
</body>

</html>